Repository navigation
G6: CSRF and cookie-flag leads (csrf_cookie_map.py) - #2225
Merged
Merged
Conversation
New report-only tool csrf_cookie_map.py, wired into review_checks.sh
--full as tool csrf-cookie, with two rules:
- missing-csrf-protection: a state-changing handler in a cookie-session
file or path realm whose own text shows no anti-forgery defence (csrf or
xsrf, or an Origin/Referer/Sec-Fetch-Site header compared against a
literal or an allow-list), and no repo-wide CSRF layer that the repo does
not disable. Django @csrf_exempt removes the layer cover. Reported at the
line that commits the change.
- missing-cookie-flags: a session-like cookie set without Secure, HttpOnly
or SameSite (Go, Express, Flask/Django, Java Cookie and ResponseCookie,
raw Set-Cookie strings). Expiry, csrf-named and variable-options cookies
are skipped.
attempt_limit_map.units gains innermost=False (Go wrapper registrations
resolve to the inner handler only when asked), resolves mid-line Django
path() calls, keeps sibling one-line Spring handlers apart and keeps a
multi-line annotation that opens with `({` in its handler's unit. Output of
cost_limit_map, attempt_limit_map and route_auth_map on the six dev
fixtures is byte-identical to main.
whole-project-report.md asks for one finding per vulnerable site.
Dev set only (the tool was built against these fixtures, so this is an
upper bound): csrf 12/12 positives, 0/8 decoys; cookie_flags 12/12, 0/8.
Three independent review rounds folded. run-ci-tests.sh --affected: 56/56
suites pass.
Tests: 71/71
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests: 71/71 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
csrf_cookie_map.py, a report-only lead-finder for CSRF-exposed cookie-session handlers and session cookies missing Secure, HttpOnly or SameSite. It is wired intoreview_checks.sh --fullas toolcsrf-cookie.missing-csrf-protectionflags a state-changing handler that relies on a session cookie and shows no defence. A defence is a csrf/xsrf token, an Origin, Referer or Sec-Fetch-Site header compared against a literal or an allow-list, or a repo-wide CSRF layer that the repo does not disable. Django@csrf_exemptremoves the layer cover.missing-cookie-flagsflags a session-like cookie set without one of the three flags.attempt_limit_map.unitsgainsinnermost=False, resolves mid-line Djangopath()calls, keeps sibling one-line Spring handlers apart, and keeps a multi-line annotation that opens with({in its handler's unit. On the six dev fixtures,cost_limit_map,attempt_limit_mapandroute_auth_mapgive byte-identical output to main (0 diffs out of 18 runs).whole-project-report.mdasks for one finding per vulnerable site.test_csrf_cookie_map.py,test_csrf_cookie_review.pyandtest_csrf_cookie_round2.py.Tests: 71/71 across the csrf-cookie, attempt-limit, cost-limit and route-auth suites.
run-ci-tests.sh --affectedpasses 56/56 suites, and regen, size-ratchet, fragments and pre-commit are green.🤖 Generated with Claude Code